<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class UserLoginRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'email'    => 'required',
            'password' => 'required',
            'captcha'  => 'required|captcha',

        ];
    }

    /*public function messages()
    {
        return [
            'email.required'    => '登录失败',
            'password.required' => '登录失败',
            'captcha.required'  => '登录失败',
            'captcha.captcha'   => '登录失败',

        ];
    }*/

    /* public function failedValidation(Validator $validator)
     {
         throw (new HttpResponseException(response()->json([
             'message' => $validator->errors()->first(),
         ], 422)));
     }*/
}
